/**
 * nodejs教程_2020年Nodejs+Koa2入门实战视频教程-2020年重新录制的Nodejs教程
 * www.itying.com 官方提供
 * 筱筱知晓
 * https://www.bilibili.com/video/BV11t411k79h?p=30
 * */
const Koa = require("koa"),
 views = require('koa-views'),
 static=require('koa-static'),
 app = new Koa();
const { log } = require("console");
//引入并实例化路由
const router=require("./router/routes");
const indexRouter=require("./router/index");
const commonState=require("./middleware/commonState");
//我们每一个模块路由都要渲染一个公共的数据,user要传到很多个模块去
app.use(views('src/views',{extension:'ejs'})).use(commonState).use(static(__dirname+'/src/static')).use(indexRouter.routes()).use(router.allowedMethods());

const port = process.env.PORT || 3000;
app.listen(port);
